import requests
from bs4 import BeautifulSoup
if __name__ == '__main__':
    # url = 'https://blog.csdn.net/justlpf/category_12229364.html'
    # res = requests.get(url)
    # soup = BeautifulSoup(res.text, 'html.parser')
    #
    # titles = []
    # for title in soup.select('.title h2'):
    #     titles.append(title.text.strip())
    #
    # print(titles)

    with open('filename.txt', 'w') as file:
        file.writelines(['Hello\n', 'world\n'])